//
//  SDPhotoMarkCell.m
//  SKinDiary
//
//  Created by pcyang on 16/7/16.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDPhotoMarkCell.h"

#define kTagLeftPadding 10
#define kTopPadding 10

@interface SDPhotoMarkCell()
@property(nonatomic,strong)UILabel* titleLabel;
@end

@implementation SDPhotoMarkCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, kTopPadding, 50, 13)];
        _titleLabel.font = [UIFont systemFontOfSize:13];
        _titleLabel.textColor = [UIColor colorWithRGB:0xb4bec8];
        _titleLabel.textAlignment = NSTextAlignmentRight;
        _titleLabel.text = @"备注";
        [self.contentView addSubview:_titleLabel];
        
        _textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 5, kPhotoMarkCellHeight - 2*kTopPadding)];
        _textView.textColor = [UIColor colorWithRGB:0x747f8b];
        _textView.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_textView];
        
        _placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectMake(4, kTopPadding - 2, 5, 13)];
        _placeHolderLabel.font = [UIFont systemFontOfSize:13];
        _placeHolderLabel.textColor = [UIColor colorWithRGB:0xb4bec8];
        _placeHolderLabel.textAlignment = NSTextAlignmentRight;
        _placeHolderLabel.text = @"最多输入20个字";
        [_placeHolderLabel sizeToFit];
        [_textView addSubview:_placeHolderLabel];
        
        UIView* bottomLineView = [[UIView alloc] initWithFrame:CGRectMake(kTagLeftPadding, kPhotoMarkCellHeight - 1, kScreenWidth - 2*kTagLeftPadding, 1)];
        [bottomLineView setBackgroundColor:[UIColor colorWithRGB:0xcad6e3]];
        [self.contentView addSubview:bottomLineView];
        
        
    }
    return self;
}

-(void)layoutSubviews
{
    _titleLabel.right = 75;
    
    _textView.left = _titleLabel.right + 10;
    _textView.width = kScreenWidth - _titleLabel.right - 20;
}

-(void)setCellData:(id)data
{
    _textView.text = data;
    if (_textView.text.length > 0 ) {
        _placeHolderLabel.hidden = YES;
    } else {
        _placeHolderLabel.hidden = NO;
    }
    [self setNeedsLayout];
}

@end
